package com.bawei.module_demo.query

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_demo.R
import com.bawei.module_demo.databinding.ItemQueryBinding

/**
 *作者：lxy
 *功能:
 *时间：2025/6/4
 */

data class QueryItem(val title: String)
class QueryAdapter(private val list: List<QueryItem>) :
    RecyclerView.Adapter<QueryAdapter.QueryViewHolder>() {


    inner class QueryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {}

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QueryViewHolder {
        val layoutInflater =
            LayoutInflater.from(parent.context).inflate(R.layout.item_query, parent, false)
        return QueryViewHolder(layoutInflater)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: QueryViewHolder, position: Int) {
        val binding = ItemQueryBinding.bind(holder.itemView)
        binding.tv.text = list[position].title
    }
}